#include <stdio.h>

int main()
{
	int a, b;
	scanf("%d%d",&a,&b);
	int arr1[a+2];
	int arr2[b+2];
	int arr3[a+b+2];
	int i = 0;
	int j = 0;
	int temp = 0;
	
	for(i = 0; i < a; i++)
	{
		scanf("%d",&arr1[i]);
		arr3[i] = arr1[i];
	}
	for(i = 0; i < b; i++)
	{
		scanf("%d",&arr2[i]);
		arr3[a+i] = arr2[i];
	}
	
	for(i = 0; i < a+b-1; i++)
	{
		for(j = 0; j < a+b-1-i; j++)
		{
			if(arr3[j]>arr3[j+1])
			{
				temp = arr3[j];
				arr3[j] = arr3[j+1];
				arr3[j+1] = temp;
			}
		}
	}
	
	for(i = 0; i < a+b; i++)
	{
		printf("%d ",arr3[i]);
	}
	
	
	return 0;
}
